{include file="public/header" /}
<body class="hide-top bgc" style="background-color: var(--f5);">
<div class="detail-hd flex-center" style="display: none">
    <i class="layui-icon layui-icon-left"></i>
    <ul>
        <li class="active pro" data-id="pro">
            <div>商品</div>
            <p></p>
        </li>
        <li class="det" data-id="spec">
            <div>详情</div>
            <p></p>
        </li>
    </ul>
</div>
<div class="detail-swiepr" id="pro">
    <div class="swiper">
        <div class="swiper-container carousel">
            <div class="swiper-wrapper">
                {foreach name="$info.images" item="vo"}
                <div class="swiper-slide" data-id="1">
                    <img src="{$vo}" alt=""/>
                </div>
                {/foreach}
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
    <i class="layui-icon layui-icon-left"></i>
</div>

<div class="detail-news">
    <div class="price">
        <p>￥<span>{$info.vip_price}</span></p>
        <p class="old">￥{$info.price}</p>
    </div>
    <p>{$info.title}</p>
    <p class="flex-layout">销量{$info.sales} <span>库存{$info.stock}</span></p>
</div>

<ul class="detail-spec-form">
<!--    <li class="det-spec">-->
<!--        <p>规格</p>-->
<!--        <input type="text" placeholder="请选择" value="7颗施华洛世奇锆·手链+礼盒证书" disabled="true">-->
<!--    </li>-->
<!--    <li>-->
<!--        <p>运费</p>-->
<!--        <input type="text" value="￥10.00">-->
<!--    </li>-->
</ul>

<div class="detail-title flex-center" id="spec">
    <span></span>商品详情 <span></span>
</div>
<div class="detail-txt">{:htmlspecialchars_decode($info['content'])}</div>
{if $info.cate_1!=3}
<div class="detail-footer flex-layout">
    <div onclick="load_href('{:url(\'cart/index\')}',2)">
        <img src="/static/index/img/icon51.png" alt="">
        <p>购物车</p>
        {if $count > 0}<span>{$count}</span>{/if}
    </div>
    <ul>
        <li>
            <img src="/static/index/img/icon52.png" alt="">
            <p>加入购物车</p>
        </li>
        <li>
            <img src="/static/index/img/icon53.png" alt="">
            <p>立即购买</p>
        </li>
    </ul>
</div>
{/if}
<div class="model">
    <div class="detail-mdl">
        <div class="detail-mdl-pro">
            <p class="flex-center">
                <img src="{$info.icon}" alt="">
            </p>
            <div class="rgt">
                <p class="price">￥<span>{$info.vip_price}</span></p>
                <p>库存 {$info.stock}</p>
                <img src="/static/index/img/icon54.png" class="cancel" alt="">
            </div>
        </div>
        <div class="model-mdl-stepper flex-layout">数量
            <div>
                {if $info.cate_1!=1}
                <p class="minus">-</p>
                {/if}
                <input type="number" value="1" id="num" readonly>
                {if $info.cate_1!=1}
                <p class="add">+</p>
                {/if}
            </div>
        </div>
        <ul class="model-mdl-btn">
            <li data-type="1" class="buy">
                <img src="/static/index/img/icon52.png" alt="">
                <p>加入购物车</p>
            </li>
            <li data-type="2" class="buy">
                <img src="/static/index/img/icon53.png" alt="">
                <p>立即购买</p>
            </li>
        </ul>
    </div>
</div>
</body>
{include file="public/footer"/}
<script src="/static/index/js/swiper-bundle.js"></script>
<script>
    $(function () {
        const ly = layer, a = $, b = a(".buy"), m = a('.minus'), d = a('.add'),
            api = {addCart: '{:url("cart/add")}', buy: '{:url("product/submit")}'};

        m.click(function () {
            const t = a(this), n = t.next(), v = parseInt(n.val());
            v > 1 ? n.val(v > 1 ? v - 1 : 1) : '';
        });
        d.click(function () {
            var t = a(this), n = t.prev(), v = parseInt(n.val());
            n.val(v + 1);
        });

        b.click(function () {
            var t = a(this).attr('data-type'), u = t === '1' ? api.addCart : api.buy, n = a("#num").val();
            return parseInt(n) > 0 ? common.request(u, {pid: '{$info.id}', num: n, type: 1}) : ly.msg('数量错误');
        })

    })

    //静态页原始数据
    var swiper = new Swiper('.carousel', {
        pagination: {
            el: '.swiper-pagination',
        },
        autoplay: {
            delay: 3000,
            disableOnInteraction: false,
        },
        loop: true
    });
    $(document).ready(function () {
        $(document).scroll(function () {
            if ($(this).scrollTop() >= 560) {
                $('.det').addClass('active').siblings().removeClass('active')
            } else {
                $('.pro').addClass('active').siblings().removeClass('active')
            }
            if ($(this).scrollTop() >= 100) {
                $(".detail-hd").show()
            } else {
                $('.detail-hd').hide()
            }
        })
    })

    $('.detail-hd li').click(function () {
        $("html,body").animate({scrollTop: $('#' + $(this).data('id')).offset().top - 44 + 'px'}, 1000);
    })
    $('.cancel').click(function () {
        $('.model').hide()
    })
    $('.detail-footer li').click(function () {
        $('.model').show()
    })
    $('.det-spec').click(function () {
        $('.model').show()
    })
</script>
</html>